import SparkMD5 from 'spark-md5';

// 当接收到消息时触发的处理函数
self.onmessage = e => {
    // 从消息中获取文件分块数组
    const {chunk, index} = e.data;

    const reader = new FileReader();

    reader.readAsArrayBuffer(chunk);
    reader.onload = e => {
        const chunkHash = SparkMD5.ArrayBuffer.hash(e.target.result);

        self.postMessage({chunkHash, index})
    }
   
};
